#include <iostream>
#include "HttpClientExample.h"

int main() {
    std::string testUrlCode = "";
    testUrlCode = WHttpClientCommon::urlEncode("张三");
    std::cout << "url encode: " << testUrlCode << std::endl;
    std::cout << "url decode: " << WHttpClientCommon::urlDecode(testUrlCode) << std::endl;

    HttpClientExample httpClientTest;
    HttpClientReqMsg reqMsg;
    reqMsg.method = "GET";
    reqMsg.querys = {{"参数1", "张三"}, {"param2", "value2"}};
    reqMsg.headers = {{"User-Agent", "MyHttpClient"}, {"Content-Type", "application/json"}};
    reqMsg.uri = "/whttpserver/test";

    std::string url = "https://localhost:6443";

    //httpClientTest.testSyncRequest(url, reqMsg);
    httpClientTest.testAsyncRequest(url, reqMsg);

    HttpClientReqMsg reqFile;
    reqFile.method = "GET";
    reqFile.uri = "/1080P.mp4";
    // reqFile.uri = "/whttpserver/chunkDownloadFile/111.mp4"; // chunk下载
    httpClientTest.testAsyncDownloadFile(url, reqFile);

    HttpClientReqMsg reqFile2;
    reqFile2.method = "GET";
    reqFile2.uri = "/111.mp4";
    // reqFile2.uri = "/whttpserver/chunkDownloadFile/111.mp4"; // chunk下载
    httpClientTest.testSyncDownloadFile(url, reqFile2);

    while(true)
    {
        httpClientTest.run();
    }

    return 0;
}    
